//
// Created by hsj on 2022/1/18.
//
#include <iostream>
#include "t_class_extend_virtual.h"
namespace hsj_class_extend_virtual{
    //需要被多态使用
    //C++的virtual目的就是达到java多态一样的效果
    void test_class_extend_virtual(){

//        Brass piggy("Porcelot Pigg",381299,4000.0);
//        BrassPlus hoggy("Horatio Hogg",38228,3000.0);
//
//        cout<<"***************************************************"<<endl;
//        piggy.viewAcct();
//        cout<<"---------------------"<<endl;
//        hoggy.viewAcct();
//        cout<<"***************************************************"<<endl;
//        hoggy.deposit(1000.0);
//        cout<<"***************************************************"<<endl;
//        piggy.withDraw(4200.0);
//        cout<<"---------------------"<<endl;
//        hoggy.withDraw(4200.0);
//        cout<<"***************************************************"<<endl;
//        piggy.viewAcct();
//        cout<<"---------------------"<<endl;
//        hoggy.viewAcct();

        Brass *piggy = new Brass("Porcelot Pigg",381299,4000.0);
        Brass *hoggy = new BrassPlus("Horatio Hogg",38228,3000.0);
        cout<<"***************************************************"<<endl;
        piggy->viewAcct();
        cout<<"---------------------"<<endl;
        hoggy->viewAcct();
        cout<<"***************************************************"<<endl;
        hoggy->deposit(1000.0);
        cout<<"***************************************************"<<endl;
        piggy->withDraw(4200.0);
        cout<<"---------------------"<<endl;
        hoggy->withDraw(4200.0);
        cout<<"***************************************************"<<endl;
        piggy->viewAcct();
        cout<<"---------------------"<<endl;
        hoggy->viewAcct();


        cout<<"***************************************************"<<endl;
        //不使用virtual函数，都是指向基类
        piggy->viewName();
        hoggy->viewName();

        delete piggy;
        delete hoggy;
    }

}